/**
*      author: Y_Yao
*      created: 2025-05-22 10:55:26
**/

#include<bits/stdc++.h>

#define int LL
using namespace std;
using LL = long long;
const LL LLINF = 9e18;
const int INF = 0x3f3f3f3f;
const int N = 100 + 7;
int n;
int a[N];

int gcd(int a,int b)
{
    if(b == 0) return a;
    return gcd(b,a % b);
}

void solve()
{
    vector<int> tmp;
    cin >> n;
    int mx = 0;
    int idx = 0;
    for(int i = 1;i <= n;i++)
    {
        cin >> a[i];
        if(a[i] > mx)
        {
            mx = a[i];
            idx = i;
        }
    }

    for(int i = 1;i <= n;i++)
    {
        if(i != idx)
        {
            tmp.push_back(a[i]);
        }
    }

    int cur = tmp[0];
    for(int i = 1;i < tmp.size();i++)
    {
        cur = gcd(cur,tmp[i]);
    }
    if(cur == mx)
    {
        cout << "No" << endl;
        return;
    }
    else
    {
        cout << "Yes" << endl;
        for(int i = 1;i <= n;i++)
        {
            if(idx == i) cout << 1 << " ";
            else cout << 2 << " ";
        }
        cout << endl;
    }
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}